$(function(){
    var url = location.href.split("#")[0].toString();//url不能写死
    $.ajax({
            type : "get",
            url : "../../mobileapi/getwxconfig.php",
            dataType : "json",
            async : false,
            data:{url:url},
            success : function(data) {
                console.log(data)
                wx.config({
                        debug: false,////生产环境需要关闭debug模式
                        appId: data.appId,//appId通过微信服务号后台查看
                        timestamp: data.timestamp,//生成签名的时间戳
                        nonceStr: data.nonceStr,//生成签名的随机字符串
                        signature: data.signature,//签名
                        jsApiList: [//需要调用的JS接口列表
                            'checkJsApi',
                            'onMenuShareTimeline',
                            'onMenuShareAppMessage',
                        ]
                    });
                },
            error:function(xhr, status, error){
            	console.log(error)
            }
    })
    wx.ready(function () {
        // 分享到朋友圈
        var descM="变美丽的秘密在这里~一周课表，总有一项适合你，戳一下有惊喜哦~"
        var title=$("#descTitle").val()
        var imgUrl=$("#descImg").val()
        var vids=sessionStorage.getItem('vid')
        var gtoken=sessionStorage.getItem('token')
        wslink = url+"?vid="+vids+"&type=share&gtoken="+gtoken
        wx.onMenuShareTimeline({
                title: title,
				desc: descM,
                link: wslink,
                imgUrl: imgUrl,
                success: function () {
                },
                cancel: function () {
                }
        });

        // 分享给朋友
        wx.onMenuShareAppMessage({
                title: title,
                desc: descM,
                link: wslink,
                imgUrl:imgUrl,
                success: function () {
                },
                cancel: function () {
                }
        });
    });

})